package com.gem.growingtree.activity;

import javax.security.auth.PrivateCredentialPermission;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class ParentRelation extends Activity {
	
	private TextView backView;
	private Button saveRelation;
	private EditText parentRelation;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_parent_relation);
		backView = (TextView) findViewById(R.id.relationback);
		saveRelation = (Button) findViewById(R.id.save_relation);
		parentRelation = (EditText) findViewById(R.id.new_parent_relation);
		
		backView.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
			Intent intent = new Intent();
			intent.setClass(ParentRelation.this, MyInformationActivity.class);
			startActivity(intent);
			}
		});		
	}

	public void saveRelation(View view) {
		String newParentRelation = parentRelation.getText().toString();
		if (newParentRelation == null) {
			Toast.makeText(this, "亲子关系不可为空！", 1).show();
		}else {
			TextView parenthood = (TextView) findViewById(R.id.parenthood);
			parenthood.setText(newParentRelation);
			Intent intent = new Intent();
			intent.setClass(ParentRelation.this, MyInformationActivity.class);
			startActivity(intent);
		}
	}
	
}
